package modelo.dominio;

import java.util.ArrayList;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;

@Entity
@Table(name ="Motorista")
@PrimaryKeyJoinColumn(name="cpf")
public class Motorista extends Pessoa{
	
	@Column(length=11, unique=true, nullable=false)
	private String cnh;
	
	@OneToMany(mappedBy="motorista")
	private List<Locacao> listaLocacoes = new ArrayList<Locacao>();
	
	public Motorista(){}

	public Motorista(String cnh) {
		this.cnh = cnh;
	}

	public Motorista(String nome, String cnh){
		super (nome);
		this.cnh = cnh;
	}
	
	public Motorista(long cpf) {
		super(cpf);
	}

	public Motorista(String cnh, String nome, long cpf, String endereco, String telefone){
		super(nome, cpf, endereco, telefone);
		this.cnh = cnh;
	}   

	public String getCnh(){
		return this.cnh;
	}

	public void setCnh(String cnh){
		this.cnh = cnh;
	}

	public String getMotorista(){
		return this.getNome();
	}
	
	@Override
	public String toString() {
		return super.toString() +
			  "\nCNH: " + this.cnh;
	}
}
